package ${packageName};

import ${basePackageName}entity.base.BoPage;
import ${basePackageName}entity.${className};
import ${basePackageName}entity.bean.${className}Req;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;

@Slf4j
@SpringBootTest
public class ${className}ServiceImplTest {

    @Resource
    private ${className}Service ${className?uncap_first}Service;


    @Test
    public void testSimpleBoPage() {

        BoPage<${className}> ${className?uncap_first}BoPage = ${className?uncap_first}Service.pageSample${className}(1, 1);

        if (${className?uncap_first}BoPage == null){
            log.error("查询BoPage对象是空的");
            return ;
        }

        if (${className?uncap_first}BoPage.getTotal() == 0 && !CollectionUtils.isEmpty(${className?uncap_first}BoPage.getList())){
            log.error("查询BoPage数据异常，total是0，但是集合有值");
            return ;
        }

        if (${className?uncap_first}BoPage.getTotal() != 0 && CollectionUtils.isEmpty(${className?uncap_first}BoPage.getList())){
            log.error("查询BoPage数据异常，total不为空，但是集合无值");
            return ;
        }

        log.info("testSimpleBoPage 一切顺利");
    }


    @Test
    public void testReqMapBoPage() {

        ${className}Req ${className?uncap_first}Req = new ${className}Req();
        ${className?uncap_first}Req.setPageNumber(1);
        ${className?uncap_first}Req.setPageSize(1);

        BoPage<${className}> ${className?uncap_first}BoPage = ${className?uncap_first}Service.pageEq${className}Dto(${className?uncap_first}Req);

        if (${className?uncap_first}BoPage == null) {
            log.error("查询BoPage对象是空的");
            return;
        }

        if (${className?uncap_first}BoPage.getTotal() == 0 && !CollectionUtils.isEmpty(${className?uncap_first}BoPage.getList())) {
            log.error("查询BoPage数据异常，total是0，但是集合有值");
            return;
        }

        if (${className?uncap_first}BoPage.getTotal() != 0 && CollectionUtils.isEmpty(${className?uncap_first}BoPage.getList())) {
            log.error("查询BoPage数据异常，total不为空，但是集合无值");
            return;
        }

        log.info("testReqMapBoPage 一切顺利");
    }


    @Test
    public void testSqlMapBoPage() {

        ${className}Req ${className?uncap_first}Req = new ${className}Req();
        ${className?uncap_first}Req.setPageNumber(1);
        ${className?uncap_first}Req.setPageSize(1);

        BoPage<${className}> ${className?uncap_first}BoPage = ${className?uncap_first}Service.page${className}Mapper(${className?uncap_first}Req);

        if (${className?uncap_first}BoPage == null) {
            log.error("查询BoPage对象是空的");
            return;
        }

        if (${className?uncap_first}BoPage.getTotal() == 0 && !CollectionUtils.isEmpty(${className?uncap_first}BoPage.getList())) {
            log.error("查询BoPage数据异常，total是0，但是集合有值");
            return;
        }

        if (${className?uncap_first}BoPage.getTotal() != 0 && CollectionUtils.isEmpty(${className?uncap_first}BoPage.getList())) {
            log.error("查询BoPage数据异常，total不为空，但是集合无值");
            return;
        }

        log.info("testSqlMapBoPage 一切顺利");
    }

}
